package com.hxg.bl.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxg.bl.bean.AppointmentPeriodTimeBean;
import com.hxg.bl.dao.jpa.AppointmentPeriodTimeBeanJpa;
import com.hxg.bl.dao.mapper.AppointmentPeriodTimeMapper;
import com.hxg.bl.service.AppointmentPeriodTimeService;
import com.hxg.bl.vo.SearchVo;
import com.hxg.common.LayuiPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Transactional
@Service("AppointmentPeriodTimeService")
public class AppointmentPeriodTimeServiceImpl implements AppointmentPeriodTimeService {

    @Autowired
    private AppointmentPeriodTimeBeanJpa appointmentPeriodTimeBeanJpa;

    @Autowired
    private AppointmentPeriodTimeMapper appointmentPeriodTimeMapper;

    @Override
    public void saveAndFlushNavTab(AppointmentPeriodTimeBean navTabBean) {
        appointmentPeriodTimeBeanJpa.saveAndFlush(navTabBean);
    }

    @Override
    public PageInfo<AppointmentPeriodTimeBean> listAppointmentPeriodTimeByParams(Integer pn, Integer pageSize,
                                                                                 SearchVo searchVo) {
        PageHelper.startPage(pn, pageSize);

        List<AppointmentPeriodTimeBean> appointmentPeriodTimeBeanList =
                appointmentPeriodTimeMapper.listAppointmentPeriodTimeByParams(searchVo);

        return new LayuiPageInfo<>(appointmentPeriodTimeBeanList);
    }

    @Override
    public void batchDelAppointmentPerimodTime(List<Long> idList) {
        appointmentPeriodTimeBeanJpa.deleteAllByIdIn(idList);
    }
}
